package com.atxwq.shop.manager.serivce.impl;

import com.atxwq.shop.manager.mapper.BrandMapper;
import com.atxwq.shop.manager.serivce.BrandService;
import com.atxwq.shop.model.entity.product.Brand;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description TODO
 * @Date 2025/5/13 14:16
 * @Created by 12336
 */

@Service
public class
BrandServiceImpl implements BrandService {

    @Autowired
    private BrandMapper brandMapper;

    /**
     * 分页查询品牌
     * @param page
     * @param limit
     * @return
     */
    @Override
    public PageInfo<Brand> findByPage(Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Brand> brandList = brandMapper.findByPage();
        return new PageInfo<>(brandList);
    }

    /**
     * 添加品牌
     * @param brand
     */
    @Override
    public void save(Brand brand) {
        brandMapper.save(brand);
    }

    /**
     * 修改品牌
     * @param brand
     */
    @Override
    public void update(Brand brand) {
        brandMapper.update(brand);
    }

    /**
     * 删除品牌
     * @param id
     */
    @Override
    public void delete(Long id) {
        brandMapper.delete(id);
    }

    /*===============================================================*/

    /**
     * 查询所有品牌
     *
     * @return
     */
    @Override
    public List<Brand> findAll() {
        //和分页查询的方法一样
       List<Brand> list =  brandMapper.findByPage();
       return list;
    }
}
